package logic

import (
	"context"
	"my-zero-tiktok/common/xerr"

	"my-zero-tiktok/apps/video/pb/pb"
	"my-zero-tiktok/apps/video/rpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type DelVideoLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDelVideoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DelVideoLogic {
	return &DelVideoLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// DelVideo 删除视频
func (l *DelVideoLogic) DelVideo(in *pb.VideoIDRequest) (*pb.Empty, error) {
	err := l.svcCtx.VideoModel.Delete(l.ctx, in.VideoId)
	if err != nil {
		return nil, xerr.New(xerr.VideoDelError)
	}
	return &pb.Empty{}, nil
}
